#ifndef PolyAccessor_HPP
#define PolyAccessor_HPP
#include "GeometryTypes.hpp"
#include <boost/signal.hpp>

class PolyAccessor
{
public:
   typedef Polyhedron Poly;

   PolyAccessor(PolyhedronList* aPolyList) : mPolyList(aPolyList) {}

   const Polyhedron& operator[](int aIndex) const
   {
      if (mPolyList != 0)
      {
         return (*mPolyList)[aIndex];
      }
      else
      {
         static Poly v;
         return v;
      }
   }

   const PolyhedronList& Get() const
   {
      return Get();
   }

   PolyhedronList& Get()
   {
      if (mPolyList) return (*mPolyList);
      static PolyhedronList v;
      return v;
   }

   boost::signal<void()> Updated;

   size_t size() const { if (mPolyList) return mPolyList->size(); else return 0; }

   bool IsValid() const { return mPolyList != 0; }

   void SetPolyList(PolyhedronList* aPolyList) { mPolyList = aPolyList; }

private:
   PolyhedronList*   mPolyList;
};

#endif